<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="流程名称" prop="ipaddr">
        <el-input
          v-model="queryParams.ipaddr"
          placeholder="请输入流程名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流程编码" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入流程编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="流程类型" prop="status">
        <el-select v-model="queryParams.type" placeholder="请选择流程类型" clearable size="small">
          <el-option
            v-for="dict in typeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['monitor:job:add']"
          >新建流程</el-button>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple-dark">
           <div class="grid-cunt">已选择<span>0</span>项</div>
            <div class="grid-clear">清空</div>
          </div>
        </el-col>
      </el-row>

    </el-form>

    <el-table
      v-loading="loading"
      :data="list.slice((pageNum-1)*pageSize,pageNum*pageSize)"
      style="width: 100%;"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="流程名称" align="center" prop="tokenId" :show-overflow-tooltip="true" />
      <el-table-column label="流程编码" align="center" prop="userName" :show-overflow-tooltip="true" />
      <el-table-column label="流程类型" align="center" prop="deptName" />
      <el-table-column label="发布状态" align="center" prop="ipaddr" :show-overflow-tooltip="true" />

      <el-table-column label="创建时间" align="center" prop="loginTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.loginTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleForceLogout(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
          >上传流程</el-button>

          <el-button
            size="mini"
            type="text"
            @click="handleForceLogout(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
          >设计流程</el-button>

          <el-button
            size="mini"
            type="text"
            @click="handleForceLogout(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
          >流程配置</el-button>

          <el-button
            size="mini"
            type="text"
            @click="handleForceLogout(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
          >发布</el-button>

          <el-dropdown trigger="click">
              <span class="el-dropdown-link">
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>版本监控</el-dropdown-item>
              <el-dropdown-item>流程复制</el-dropdown-item>
              <el-dropdown-item>表单图标</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>

        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />
  </div>
</template>

<script>
import { list, forceLogout } from "@/api/monitor/online";

export default {
  name: "Online",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      pageNum: 1,
      pageSize: 10,
      // 查询参数
      queryParams: {
        ipaddr: undefined,
        userName: undefined,
        type: undefined
      },
      typeOptions:[
        {
          dictValue: '1',
          dictLabel:'21'
        }
      ]
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询登录日志列表 */
    getList() {
      this.loading = true;
      list(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /*新增*/
    handleAdd(){

    },
    /** 强退按钮操作 */
    handleForceLogout(row) {
      // this.$confirm('是否确认强退名称为"' + row.userName + '"的数据项?', "警告", {
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   type: "warning"
      // }).then(function() {
      //   return forceLogout(row.tokenId);
      // }).then(() => {
      //   this.getList();
      //   this.msgSuccess("强退成功");
      // }).catch(function() {});
    }
  }
};
</script>

<style>
.el-row {
  margin-bottom: 20px;
}
.el-row :last-child {
  margin-bottom: 0;
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: rgba(230,247,255,1);
  border: 1px solid rgba(145,213,255,1);
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
  line-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

/*栅格-选择数*/
.grid-cunt{
  width: 100px;
  margin: 0 10px 0 40px;
  float: left;
  font-size: 16px;
  color: rgba(86,92,95,1);
}
.grid-cunt span{
  margin: 0 5px 0 5px;
  color: rgba(24,144,255,1);
}
.grid-clear{
  font-size: 16px;
  color: rgba(24,144,255,1);
  cursor: pointer;
}
.el-dropdown {
  cursor: pointer;
  display: inline-block;
  position: relative;
  color: #409EFF;
  font-size: 12px;
  margin-left: 10px;
}
</style>

